//
//  UIBarButtonItem+HRBarButtonItem.swift
//  weiBo
//
//  Created by helong on 16/7/10.
//  Copyright © 2016年 helong. All rights reserved.
//

// MARK: - 自定义的UIBarButtonItem的分类,统一给上面的按钮设置属性
import UIKit
extension UIBarButtonItem{
    
    convenience init(title: String, target: AnyObject?, action: Selector){
        //便利构造函数调用父类的方法用self,不能用super
        self.init()
        //设置属性
        let btn = UIButton()
        btn.setTitle(title, forState: .Normal)
        btn.setTitleColor(UIColor.orangeColor(), forState: .Highlighted)
        btn.setTitleColor(UIColor.darkGrayColor(), forState: .Normal)
        btn.addTarget(target, action: action, forControlEvents: .TouchUpInside)
        //让按钮的大小适应内容
        btn.sizeToFit()
        //
        customView = btn
        
    }
    
}